import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/app`

export function getAppnameList(params) {
  return request.get(`${AUTH_PREFIX_V1}/appnames`, { params }).then(res => camelCaseObject(res))
}

export function getAppnameListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/appnames/page`, { params }).then(res => camelCaseObject(res))
}

export function getAppname(appnameId) {
  return request.get(`${AUTH_PREFIX_V1}/appnames/${appnameId}`).then(res => camelCaseObject(res))
}

export function createAppname(params) {
  return request.post(`${AUTH_PREFIX_V1}/appnames`, params).then(res => camelCaseObject(res))
}

export function updateAppname(appnameId, params) {
  return request.put(`${AUTH_PREFIX_V1}/appnames/${appnameId}`, params).then(res => camelCaseObject(res))
}

export function deleteAppname(appnameId) {
  return request.delete(`${AUTH_PREFIX_V1}/appnames/${appnameId}`).then(res => camelCaseObject(res))
}
